WIP: map_identity
: suggest making the variable mutable when necessary
#15268
+99
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on #15229, I noticed a test case in
map_identity
which avoids linting in the case where removing the.map()
would require the iterator variable to be made mutable. But then I saw #14140, and thought I'd try to adapt its approach, by suggesting both removing the.map()
and making the variable mutable.This is WIP only because I'm not sure about the very last
diag.span_note
-- I think having a method chained immediately after the.map()
is the only case which requires addingmut
, so it should be safe to say thatmethod_requiring_mut
is alwaysSome
. I'd like to do a lintcheck run to see if that's actually true.@samueltardieu do you think this is a good approach? Maybe there are more lints where we could lint + suggest making the variable mut, instead of not linting?
changelog:
map_identity
: suggest making the variable mutable when necessary